﻿<UserControl x:Class="StockholmsStad.Windows.UI.Modules.Couple.Views.CouplesListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Converters="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Converters;assembly=StockholmsStad.Windows.UI.Infrastructure">
    <UserControl.Resources>
        <Converters:DateTimeToDateString x:Key="dateTimeConverter" />
        <Converters:BoolToStringConverter x:Key="boolToStringConverter" />
        <Converters:PersonalNumberConverter x:Key="personalNumberConverter" />
    </UserControl.Resources>
    
    <GroupBox Header="Sök par" BorderBrush="#FF0F68A6" Background="Transparent" BorderThickness="1,1,1,1">

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <StackPanel Orientation="Vertical" Grid.Row="0">
                <StackPanel Orientation="Horizontal">
                    <Label x:Name="lblPartOfName" Content="Del av namn:" />
                    <Label x:Name="lblPartOfBirthday" Content="Del av födelsedatum:" Margin="65,0,0,0" />
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBox x:Name="tbPartOfName" Text="" Width="140" Height="22" Margin="5,0,0,0" MaxLength="8" />
                    <TextBox x:Name="tbPartOfBirth" Text="" Width="120" Height="22" Margin="10,0,10,0" MaxLength="8" />
                    <RadioButton x:Name="rbActive" Content="Pågående" Margin="10,0,10,0" Padding="5,0,0,0" IsChecked="True" VerticalAlignment="Center" />
                    <RadioButton x:Name="rbNonActive" Content="Avslutade" Margin="10,0,10,0" Padding="5,0,0,0" VerticalAlignment="Center" />
                    <Button x:Name="btnSearch" Content="Sök" Width="70" Height="22" Margin="10,0,0,0" Click="btnSearch_Click" />
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                </StackPanel>
            </StackPanel>

            <ListView x:Name="listViewUsers" Margin="5,10,5,5" SelectedIndex="0" Grid.Row="1"
                      ScrollViewer.VerticalScrollBarVisibility="Auto"
                      ItemsSource="{Binding}" SelectionChanged="listViewPerson_SelectionChanged" >
                <ListView.View>
                    <GridView ColumnHeaderContainerStyle="{DynamicResource GridViewColumnHeaderStyle1}" AllowsColumnReorder="False">
                        <GridView.Columns>
                            <GridViewColumn Header="Person1">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Person1Birthday, Converter={StaticResource personalNumberConverter}}" 
                                                       VerticalAlignment="Top" HorizontalAlignment="Left" Width="90" TextWrapping="NoWrap" />
                                            <TextBlock Text="" Width="10" />
                                            <TextBlock Text="{Binding Person1FirstName}" VerticalAlignment="Top" HorizontalAlignment="Left" TextWrapping="NoWrap" />
                                            <TextBlock Text="" Width="5" />
                                            <TextBlock Text="{Binding Person1LastName}" VerticalAlignment="Top" HorizontalAlignment="Left" TextWrapping="NoWrap" />
                                        </StackPanel>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Person2">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Person2Birthday, Converter={StaticResource personalNumberConverter}}" 
                                                       VerticalAlignment="Top" HorizontalAlignment="Left" Width="90" TextWrapping="NoWrap" />
                                            <TextBlock Text="" Width="10" />
                                            <TextBlock Text="{Binding Person2FirstName}" VerticalAlignment="Top" HorizontalAlignment="Left" TextWrapping="NoWrap" />
                                            <TextBlock Text="" Width="5" />
                                            <TextBlock Text="{Binding Person2LastName}" VerticalAlignment="Top" HorizontalAlignment="Left" TextWrapping="NoWrap" />
                                        </StackPanel>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Datum" DisplayMemberBinding="{Binding BookingDate, Converter={StaticResource dateTimeConverter}}" />
                            <GridViewColumn Header="Ceremoni" DisplayMemberBinding="{Binding CeremonyType}" />
                            <GridViewColumn Header="Status" DisplayMemberBinding="{Binding Status}" />
                            <GridViewColumn Header="SP">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding ProtectedIdentity, Converter={StaticResource boolToStringConverter}}" 
                                                   VerticalAlignment="Top" HorizontalAlignment="Center" Width="15" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="HP">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding ImpedimentDocIssuedDate, Converter={StaticResource dateTimeConverter}}" 
                                                   VerticalAlignment="Top" HorizontalAlignment="Center" Width="80" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Notering" DisplayMemberBinding="{Binding Note}" />
                        </GridView.Columns>
                    </GridView>
                </ListView.View>
            </ListView>

        </Grid>

    </GroupBox>

</UserControl>
